package com.aliothservice.catfish.product.data;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.springframework.data.annotation.Id;

public class VehiclePending {
	
	public Map<String, String> toMap() {
		Map<String, String> map = new HashMap<String, String>();
		
		map.put("id", this.getId());
		if (null != this.getLicensePlate()) {
			map.put("licensePlate", this.getLicensePlate());
		}
		if (null != this.getProvince()) {
			map.put("province", this.getProvince());
		}
		if (null != this.getCity()) {
			map.put("city", this.getCity());
		}
		if (null != this.getDistrict()) {
			map.put("district", this.getDistrict());
		}
		if (null != this.getPurchaseDate()) {
			DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
			map.put("purchaseDate", formatter.format(this.getPurchaseDate()));
		}
		if (null != this.getFullLoadWeight()) {
			map.put("fullLoadWeight",this.getFullLoadWeight().toString());
		}
		if (null != this.getFullLoadMass()) {
			map.put("fullLoadMass", this.getFullLoadMass().toString());
		}
		if (null != this.getVehiclePhotoId()) {
			map.put("vehiclePhotoId", this.getVehiclePhotoId());
		}
		if (null != this.getVehicleInsidePhotoId()) {
			map.put("vehicleInsidePhotoId", this.getVehicleInsidePhotoId());
		}
		if (null != this.getTemperatureMin()) {
			map.put("temperatureMin", this.getTemperatureMin().toString());
		}
		if (null != this.getTemperatureMax()) {
			map.put("temperatureMax", this.getTemperatureMax().toString());
		}
		if (null != this.getLengthDef()) {
			map.put("lengthDef", this.getLengthDef());
		}
		if (null != this.getOwner()) {
			map.put("owner", this.getOwner());
		}
		if (null != this.getOdometer()) {
			map.put("odometer", this.getOdometer().toString());
		}
		if (null != this.getTransportationLicenseImageId()) {
			map.put("transportationLicenseImageId", this.getTransportationLicenseImageId());
		}
		if (null != this.getInsuranceImageId()) {
			map.put("insuranceImageId", this.getInsuranceImageId());
		}
		if (null != this.getDescriptionOfReject()) {
			map.put("descriptionOfReject", this.getDescriptionOfReject());
		}
		if (null != this.getExpiredBy()) {
			DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
			map.put("expiredBy", formatter.format(this.getExpiredBy()));
		}
		if (null != this.getLastUpdateTime()) {
			DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
			map.put("lastUpdateTime", formatter.format(this.getLastUpdateTime()));
		}
		if (null != this.getManInChargeName()) {
			map.put("manInChargeName", this.getManInChargeName());
		}
		if (null != this.getManInChargePhoneNumber()) {
			map.put("manInChargePhoneNumber", this.getManInChargePhoneNumber());
		}
		if (null != this.getRefId()) {
			map.put("refId", this.getRefId());
		}
		
		return map;
	}

	@Id
	private String id;
	private String refId;
	
	// who owns this vehicle
	private String userId;

	// cannot be modified once approved
	private String licensePlate;
	private String province;
	private String city;
	private String district;
	private Date purchaseDate;
	private Integer fullLoadWeight;
	private Integer fullLoadMass;
	private String vehiclePhotoId; // stored in GridFS
	private String vehicleInsidePhotoId; // stored in GridFS
	private Integer temperatureMin;
	private Integer temperatureMax;
	// links to VehicleLengthDef.identifier
	private String lengthDef;
	
	// can be modified after approval
	private String owner;
	private Integer odometer;
	private String transportationLicenseImageId; // stored in GridFS
	private String insuranceImageId; // stored in GridFS
	
	private String manInChargeName;
	private String manInChargePhoneNumber;
	
	private String status;
	private String descriptionOfReject;
	private Date expiredBy;
	
	private Date lastUpdateTime;
	
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getLicensePlate() {
		return licensePlate;
	}

	public void setLicensePlate(String licensePlate) {
		this.licensePlate = licensePlate;
	}

	public String getProvince() {
		return province;
	}

	public void setProvince(String province) {
		this.province = province;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public Date getPurchaseDate() {
		return purchaseDate;
	}

	public void setPurchaseDate(Date purchaseDate) {
		this.purchaseDate = purchaseDate;
	}

	public Integer getFullLoadWeight() {
		return fullLoadWeight;
	}

	public void setFullLoadWeight(Integer fullLoadWeight) {
		this.fullLoadWeight = fullLoadWeight;
	}

	public Integer getFullLoadMass() {
		return fullLoadMass;
	}

	public void setFullLoadMass(Integer fullLoadMass) {
		this.fullLoadMass = fullLoadMass;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}
	
	public String getDescriptionOfReject() {
		return descriptionOfReject;
	}

	public void setDescriptionOfReject(String descriptionOfReject) {
		this.descriptionOfReject = descriptionOfReject;
	}

	public String getOwner() {
		return owner;
	}

	public void setOwner(String owner) {
		this.owner = owner;
	}

	public String getVehiclePhotoId() {
		return vehiclePhotoId;
	}

	public void setVehiclePhotoId(String vehiclePhotoId) {
		this.vehiclePhotoId = vehiclePhotoId;
	}

	public Integer getOdometer() {
		return odometer;
	}

	public void setOdometer(Integer odometer) {
		this.odometer = odometer;
	}

	public String getTransportationLicenseImageId() {
		return transportationLicenseImageId;
	}

	public void setTransportationLicenseImageId(String transportationLicenseImageId) {
		this.transportationLicenseImageId = transportationLicenseImageId;
	}

	public String getInsuranceImageId() {
		return insuranceImageId;
	}

	public void setInsuranceImageId(String insuranceImageId) {
		this.insuranceImageId = insuranceImageId;
	}

	public Integer getTemperatureMin() {
		return temperatureMin;
	}

	public void setTemperatureMin(Integer temperatureMin) {
		this.temperatureMin = temperatureMin;
	}

	public Integer getTemperatureMax() {
		return temperatureMax;
	}

	public void setTemperatureMax(Integer temperatureMax) {
		this.temperatureMax = temperatureMax;
	}

	public String getLengthDef() {
		return lengthDef;
	}

	public void setLengthDef(String lengthDef) {
		this.lengthDef = lengthDef;
	}

	public Date getExpiredBy() {
		return expiredBy;
	}

	public void setExpiredBy(Date expiredBy) {
		this.expiredBy = expiredBy;
	}

	public Date getLastUpdateTime() {
		return lastUpdateTime;
	}

	public void setLastUpdateTime(Date lastUpdateTime) {
		this.lastUpdateTime = lastUpdateTime;
	}

	public String getManInChargeName() {
		return manInChargeName;
	}

	public void setManInChargeName(String manInChargeName) {
		this.manInChargeName = manInChargeName;
	}

	public String getManInChargePhoneNumber() {
		return manInChargePhoneNumber;
	}

	public void setManInChargePhoneNumber(String manInChargePhoneNumber) {
		this.manInChargePhoneNumber = manInChargePhoneNumber;
	}

	public String getVehicleInsidePhotoId() {
		return vehicleInsidePhotoId;
	}

	public void setVehicleInsidePhotoId(String vehicleInsidePhotoId) {
		this.vehicleInsidePhotoId = vehicleInsidePhotoId;
	}

	public String getDistrict() {
		return district;
	}

	public void setDistrict(String district) {
		this.district = district;
	}

	public String getRefId() {
		return refId;
	}

	public void setRefId(String refId) {
		this.refId = refId;
	}

	public static final String STATUS_UPSERTED = "upserted";
	public static final String STATUS_READY_FOR_REVIEW = "ready_for_review";
	public static final String STATUS_ACCEPTED = "accepted";
	public static final String STATUS_REJECTED = "rejected";
	
}
